﻿using System;
using System.Data;
using Helper.DalHelper;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestProject_WcfServer.Helper.Tests.DalHelper
{
    [TestClass]
    public class SqlParameterBuilderTest
    {
        [TestMethod]
        public void should_method_createsqlparameter_with_any_value()
        {
            var paramName = "Paremeter1";

            var sqlParameter = SqlParameterBuilder.CreateSqlParameter(paramName, SqlDbType.Int, 1);

            Assert.IsNotNull(sqlParameter);

            Assert.AreEqual(sqlParameter.ParameterName, paramName);

            Assert.AreEqual(sqlParameter.Value, 1);

            Assert.IsInstanceOfType(sqlParameter.SqlDbType, SqlDbType.Int.GetType());
        }

        [TestMethod]
        public void should_method_createsqlparameter_with_null_value()
        {
            var paramName = "Paremeter1";

            var sqlParameter = SqlParameterBuilder.CreateSqlParameter(paramName, SqlDbType.Int, null);

            Assert.IsNotNull(sqlParameter);

            Assert.AreEqual(sqlParameter.ParameterName, paramName);

            Assert.IsInstanceOfType(sqlParameter.SqlDbType, SqlDbType.Int.GetType());

            Assert.AreEqual(sqlParameter.Value,DBNull.Value);
        }

        [TestMethod]
        public void should_method_createsqlparameter_parametersize_with_any_value()
        {
            var paramName = "Paremeter1";

            var sqlParameter = SqlParameterBuilder.CreateSqlParameter(paramName, SqlDbType.Int, 1,3);

            Assert.IsNotNull(sqlParameter);

            Assert.AreEqual(sqlParameter.ParameterName, paramName);

            Assert.AreEqual(sqlParameter.Value, 1);

            Assert.IsInstanceOfType(sqlParameter.SqlDbType, SqlDbType.Int.GetType());
            
            Assert.AreEqual(sqlParameter.Size, 3);
        }

        [TestMethod]
        public void should_method_createsqlparameter_parametersize_with_null_value()
        {
            var paramName = "Paremeter1";

            var sqlParameter = SqlParameterBuilder.CreateSqlParameter(paramName, SqlDbType.Int, null,6);

            Assert.IsNotNull(sqlParameter);

            Assert.AreEqual(sqlParameter.ParameterName, paramName);

            Assert.IsInstanceOfType(sqlParameter.SqlDbType, SqlDbType.Int.GetType());

            Assert.AreEqual(sqlParameter.Value, DBNull.Value);

            Assert.AreEqual(sqlParameter.Size, 6);
        }
    }
}